package com.chenjiajin.domain;


import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.format.DateTimeFormat;
import com.alibaba.excel.annotation.format.NumberFormat;
import com.alibaba.excel.annotation.write.style.ContentRowHeight;
import com.alibaba.excel.annotation.write.style.ContentStyle;
import com.alibaba.excel.annotation.write.style.HeadRowHeight;
import com.chenjiajin.converter.DateConverter;
import com.chenjiajin.converter.GenderConverter;
import lombok.Data;
import org.apache.poi.ss.usermodel.HorizontalAlignment;

import java.io.InputStream;
import java.math.BigDecimal;
import java.net.URL;
import java.util.Date;

/**
 * 导出 easyExcel
 */
@Data
@HeadRowHeight(35)    // 表头行高
@ContentRowHeight(25) // 内容行高
@ContentStyle(horizontalAlignment = HorizontalAlignment.CENTER)
//@ColumnWidth(value = 50)      // 列宽  列宽注解存在不能自适应宽度
public class DemoExport {


    @ExcelProperty(value = "名字", order = 10)      // 可以自定义列的顺序: order的值越大，列越往右
    private String name;

    @ExcelProperty("年龄")
    private Integer age;

    @ExcelProperty("唛头")
    private String mark;

    @ExcelProperty("数量")
    @NumberFormat("##.00")
    private BigDecimal number;

    @ExcelProperty("金额")
    @NumberFormat("##.00")
    private BigDecimal money;

    @ExcelProperty(value = "时间", converter = DateConverter.class)
    private Long depositPayTime;

    //@ExcelIgnore  //表示忽略导出
    @ExcelProperty("时间2")
    @DateTimeFormat("yyyy-MM-dd HH:mm:ss")
    private Date createTime;


    @ExcelProperty(value = "性别", converter = GenderConverter.class) // 性别 1:男 2:女
    private Integer gender;

    private String img;

    @ExcelProperty(value = "头像")
    private URL imgUrl;

    @ExcelProperty(value = "头像2")
    private InputStream inputStream;

}
